<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib uri="http://eureka.yigolden.net/stringutils/sutaglib/1.0" prefix="su"%>
<c:choose>
 <c:when test="${user != null && bookitem.owner.UID eq user.UID }">
  <c:set var="sellerAccess" value="1" scope="request" />
 </c:when>
 <c:otherwise>
  <c:set var="sellerAccess" value="0" scope="request" />
 </c:otherwise>
</c:choose>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head> 
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
  <!-- Attach our CSS --> 
  <link type="text/css" href="${staticResources}/css/confirmpurchase.css" rel="stylesheet" /> 
  <!-- Attach necessary scripts --> 
  <script type="text/javascript" src="${staticResources}/js/jquery-1.4.4.min.js"></script> 
  <!-- <script type="text/javascript" src="http://code.jquery.com/jquery-1.6.min.js"></script> --> 
  <script type="text/javascript" src="${staticResources}/js/jquery.reveal.js"></script> 
  <style type="text/css">
	body { font-family: "HelveticaNeue","Helvetica-Neue", "Helvetica", "Arial", sans-serif; }
			
</style> 
  <title>查看${fn:escapeXml(bookitem.name)}的详细信息</title> 
  <link type="text/css" href="${staticResources}/css/showbook.css" rel="stylesheet" /> 
  <script type="text/javascript" src="${staticResources}/js/ajax.js"></script> 
  <script type="text/javascript">
function gotostate() {
	<%
	  if ("1".equals("" + request.getAttribute("sellerAccess"))) {
	%>
	tabextend("state");
	<% } %>
}
function tabextend(name) {
	var bedes = document.getElementById("des");
	var deold = document.getElementById("old");
	var benote = document.getElementById("note");
	var state = document.getElementById("state");
	var ades = document.getElementById("ades");
	var aold = document.getElementById("aold");
	var anote = document.getElementById("anote");
	var astate = document.getElementById("astate");
	switch (name)
	{
		case 'des':
			ades.style.background="#BBFFDD";
			aold.style.background="#FFFFFF";
			anote.style.background="#FFFFFF";
			astate.style.background="#FFFFFF";
			bedes.style.display="block";
			deold.style.display="none";
			benote.style.display="none";
			state.style.display="none";
			break;
		case 'old':
			ades.style.background="#FFFFFF";
			aold.style.background="#BBFFDD";
			anote.style.background="#FFFFFF";
			astate.style.background="#FFFFFF";
			bedes.style.display="none";
			deold.style.display="block";
			benote.style.display="none";
			state.style.display="none";
			break;
		case 'note':
			ades.style.background="#FFFFFF";
			aold.style.background="#FFFFFF";
			anote.style.background="#BBFFDD";
			astate.style.background="#FFFFFF";
			bedes.style.display="none";
			deold.style.display="none";
			benote.style.display="block";
			state.style.display="none";
			break;
		case 'state':
			ades.style.background="#FFFFFF";
			aold.style.background="#FFFFFF";
			anote.style.background="#FFFFFF";
			astate.style.background="#BBFFDD";
			bedes.style.display="none";
			deold.style.display="none";
			benote.style.display="none";
			state.style.display="block";
			break;
	}
}
function collect() {
	var beid = document.getElementById("beid").value;
	var redirect_url = document.getElementById("redirect_url").value;
	var mode="ajax";
	
	var params="beid=" + encodeURIComponent(beid);
	params+="&redirect_url="+encodeURIComponent(redirect_url);
	params+="&mode="+encodeURIComponent(mode);

	doAjax("AddToFavorite"
			,params,function(rst){
		var rst=eval('(' +rst+ ')');
		if(rst.status == 0) {
			window.alert("成功加入收藏夹！");
		} else  {
			window.alert(rst.message);
		}
	});
}
function onshelf(beid) {
	var mode = "ajax";
	var params = "beid=" + encodeURIComponent(beid);
	params += "&mode=" + encodeURIComponent(mode);
	
	doAjax("BookOnshelf"
			,params,function(rst){
		var rst=eval('(' +rst+ ')');
		if(rst.status == 0) {
			window.alert("成功上架！");
			location.reload();
		} else  { 
			window.alert(rst.message);
		}
	});
}
function offshelf(beid)
{
	var mode = "ajax";
	var params = "beid=" + encodeURIComponent(beid);
	params += "&mode=" + encodeURIComponent(mode);
	
	doAjax("BookOffshelf"
			,params,function(rst){
		var rst=eval('(' +rst+ ')');
		if(rst.status == 0) {
			window.alert("成功下架！");
			location.reload();
		} else  { 
			window.alert(rst.message);
		} 
	});
}
</script> 
<script type="text/javascript">
function loadCP() {
	document.getElementById("cp_frame").src="${contextPath }/Transactions/ConfirmPurchase?beid=${bookitem.beID }";
}
function loadSA() {
	document.getElementById("sa_frame").src="${contextPath }/Auctions/StartAuction?beid=${bookitem.beID }";
}
</script> 
 </head> 
 <body onload="gotostate();"> 
<div id="header">
  <div id="hy">
    <c:if test="${user eq null }">
    <div id="logo">欢迎光临中国药科大学二手书交易平台!请<span><a href="${contextPath }/Account/Login">登录</a></span> 免费<span><a href="${contextPath }/Account/Register">注册</a></span></div>
    </c:if>
    <c:if test="${user ne null }">
    <div id="sc">
      <ul>
        <li><a href="${contextPath }/Account/Logout">注销</a></li>
        <li><a href="${contextPath }/Me?content=201">收藏夹</a></li>
        <li><a href="${contextPath }/Me">个人中心</a></li>
        <li>欢迎你，<b>${fn:escapeXml(user.nickName) }</b>！</li>
      </ul>
    </div>
    </c:if>
    
    
  </div>
  <div id="top"><img src="${staticResources}/image/zhuye_04.gif" width="1024" height="153" alt=""></div>
  <div id="nav" style="background:url(${staticResources}/image/zhuye_06.gif)">
    <ul>
      <li><a href="${contextPath }/Homepage">首页</a></li>
      <li><a href="${contextPath }/Books/Search">交易广场</a></li>
      <li><a href="${contextPath }/Auctions/Search">拍卖中心</a></li>
      <li><a href="#">读者推荐</a></li>
      <li><a href="${contextPath }/Comment/ListComments">留言板</a></li>
      <li><a href="#">新手指南</a></li>
    </ul>
  </div>
</div>
  <!--头部结束--> 
  <div class="main" style="margin: 0px auto; height:auto;"> 
   <div class="lmain" style=" height:auto;">
    <span><img src="${staticResources}/image/zhuye_10.gif" width="179" height="35" alt="" /></span> 
    <dl class="tsfl"> 
     <dd> 
      <a href="#">小说 </a>
     </dd> 
     <dt>
      <a href="#"> 言情 武侠 名著 军事 悬疑 职场</a>
     </dt> 
     <dd>
      <a href="#"> 期刊</a>
     </dd> 
     <dt>
      <a href="#"> 财经 漫画 英文 杂志</a>
     </dt> 
     <dd>
      <a href="#">文学</a>
     </dd> 
     <dt>
      <a href="#"> 诗歌 散文 文集 外国诗歌</a>
     </dt> 
     <dd>
      <a href="#"> 教科书 </a>
     </dd> 
     <dt>
      <a href="#">化学 物理 生物 英语 计算机 药理</a>
     </dt> 
     <dd>
      <a href="#"> 教辅用书</a>
     </dd> 
     <dt>
      <a href="#"> 药院 中药院 商院 生科院 理学院</a>
     </dt> 
     <dd>
      <a href="#"> 人文社科</a>
     </dd> 
     <dt>
      <a href="#"> 商务礼仪 宗教 历史 法律 心理学</a>
     </dt> 
     <dd>
      <a href="#"> 艺术</a>
     </dd> 
     <dt>
      <a href="#"> 摄影 绘画 音乐 舞蹈 书法 篆刻</a>
     </dt> 
     <dd>
      <a href="#"> 成功励志</a>
     </dd> 
     <dt>
      <a href="#"> 礼仪 人际交往 口才 留学 哲学</a>
     </dt> 
     <dd>
      <a href="#"> 其他</a>
     </dd> 
     <dt>
      <a href="#">...</a>
     </dt> 
    </dl> 
    <dl class="phb"> 
     <span><img src="${staticResources}/image/zhuye_37.gif" width="177" height="35" alt="" /></span> 
     <div id="nn"> 
      <ul> 
       <li><a href="#">教科</a></li> 
       <li><a href="#">小说</a></li> 
       <li><a href="#">期刊</a></li> 
       <li><a href="#">其他</a></li> 
      </ul> 
     </div> 
     <dd>
      <a href="#"><img src="${staticResources}/image/zhuye_43.gif" width="64" height="74" alt="" />书名：<br />价格：<br />卖家信息：</a> 
     </dd> 
     <dd>
      <a href="#"><img src="${staticResources}/image/zhuye_43.gif" width="64" height="74" alt="" />书名：<br />价格：<br />卖家信息：</a> 
     </dd> 
     <dd>
      <a href="#"><img src="${staticResources}/image/zhuye_43.gif" width="64" height="74" alt="" />书名：<br />价格：<br />卖家信息：</a> 
     </dd> 
    </dl> 
   </div> 
   <div class="rmain"> 
    <div class="intro"> 
     <div class="book"> 
      <div class="pic">
       <img src="${contextPath}/Books/GetBookPicture?beid=${bookitem.beID}&size=min" style="max-height: 340px; max-width: 270px;" alt="" />
      </div> 
      <div class="name"> 
       <dl style="font-size:28px ;font-weight:1000">
        ${fn:escapeXml(bookitem.name)}
       </dl>
       <small><a href="ShowBasicBook?bbid=${bookitem.bbID}" style="font-size:16px;font-weight:1000">&gt;&gt;找同款</a></small>
       <br /> 
       <small>版本：${fn:escapeXml(bookitem.version)}</small>
       <br /> 
       <small>出版社：${fn:escapeXml(bookitem.publisher)}</small>
       <br /> 
       <small>主编：${fn:escapeXml(bookitem.chiefEditor)}</small>
       <br /> 
       <small>分类：${fn:escapeXml(bookitem.category.name)}</small>
       <br /> 
       <span style="font-size:28px ;font-weight:1000">价格：</span>
       <b style="font-size:30px;font-weight:1000">￥${fn:escapeXml(bookitem.price)}</b>
       <br /> 
       <small>卖家昵称：${fn:escapeXml(bookitem.owner.nickName)}</small>
       <br /> 
       <small>新旧程度：${fn:escapeXml(bookitem.conditionFriendlyName)}</small>
       <br /> 
       <small>笔记情况：${fn:escapeXml(bookitem.hasNoteFriendlyName)}</small>
       <br /> 
       <small>发布时间：${fn:escapeXml(bookitem.formattedLastSateChangedTime)}</small>
       <br /> 
      </div> 
      <div class="botton"> 
       <div class="bts"> 
        <c:choose>
          <c:when test="${sellerAccess eq 1 && bookitem.state.code eq 2 }">
           <div class="b1"> 
            <a href="UploadPicture?beid=${bookitem.beID}"><img src="${staticResources}/image/upload_picture_button.gif" width="200" height="60" alt="" /></a> 
           </div> 
           <div class="b2"> 
            <a href="${contextPath }/Auctions/ShowAuction?beid=${bookitem.beID}"><img src="${staticResources}/image/goto_auction.gif" width="200" height="60" alt="" /></a> 
           </div> 
          </c:when>
          <c:when test="${sellerAccess eq 1 }">
           <div class="b2"> 
            <a href="UploadPicture?beid=${bookitem.beID}"><img src="${staticResources}/image/upload_picture_button.gif" width="200" height="60" alt="" /></a> 
           </div> 
          </c:when>
          <c:when test="${bookitem.state.code eq 2 }">
           <div class="b2"> 
            <a href="${contextPath }/Auctions/ShowAuction?beid=${bookitem.beID}"><img src="${staticResources}/image/goto_auction.gif" width="200" height="60" alt="" /></a> 
           </div> 
          </c:when>
          <c:otherwise>
           <div class="b1"> 
            <a href="#" class="big-link" data-reveal-id="cpModal" data-animation="fade" onclick="loadCP();"><img src="${staticResources}/image/showbook_06.gif" width="200" height="60" alt="" /></a> 
           </div> 
           <div class="b2"> 
            <a href="#" onclick="collect(${bookitem.beID});return false;"><img src="${staticResources}/image/showbook_08.gif" width="200" height="60" alt="" /></a> 
           </div> 
          </c:otherwise>
        </c:choose>
       </div> 
      </div> 
     </div> 
    </div> 
    <div class="detail"> 
     <div id="nav2"> 
      <ul> 
       <li><a href="#" onclick="tabextend('des');return false" id="ades" style="background :#BBFFDD">卖家描述</a></li> 
       <li><a href="#" onclick="tabextend('old');return false" id="aold">新旧程度</a></li> 
       <li><a href="#" onclick="tabextend('note');return false" id="anote">笔记情况</a></li> 
       <li><a href="#" onclick="tabextend('state');return false" id="astate">书籍状态</a></li> 
      </ul> 
     </div> 
     <br /> 
     <div class="con" id="des" style="display : block ; border-width : 1px"> 
      <dl> 
       <dd style="font-size : 16px ; font-weight :900">
        卖家描述
       </dd> 
       <dt>
        ${fn:escapeXml(bookitem.description)}
       </dt> 
       <c:if test="${bookpics_count != null && bookpics_count gt 0}">
        <dd style="font-size : 16px ; font-weight :900">
          图片
        </dd>
        <c:forEach var="bookpic" items="${bookpics}">
         <dt>
          <img src="${userContents }/bepics/${bookpic.completeFileName}" style="max-width:800px;max-height:600px;" />
         </dt>
        </c:forEach>
       </c:if>

      </dl> 
     </div> 
     <div class="con" id="old" style="display : none ; border-width : 1px"> 
      <dl> 
       <dd style="font-size : 16px ; font-weight :900">
        新旧程度
       </dd> 
       <dt>
        ${fn:escapeXml(bookitem.conditionFriendlyName)}
       </dt> 
      </dl> 
     </div> 
     <div class="con" id="note" style="display : none ; border-width : 1px"> 
      <dl> 
       <dd style="font-size : 16px ; font-weight :900">
        笔记情况
       </dd> 
       <dt>
        ${fn:escapeXml(bookitem.hasNoteFriendlyName)}
       </dt> 
      </dl> 
     </div> 
     <div class="con" id="state" style="display : none ; border-width : 1px"> 
      <dl> 
       <dd style="font-size : 16px ; font-weight :900">
        书籍状态
       </dd> 
       <dt>
        当前状态：<b>${fn:escapeXml(bookitem.state.friendlyName) }</b>
        <br />
        <c:if test="${sellerAccess eq 1 }">
         <c:set var="op_counter" value="0" />
          操作：&nbsp;<b>
          <c:if test="${bookitem.state.code eq 0 }">
           <a href="#" onclick="onshelf(${bookitem.beID});return false;" style="color:blue;">上架</a>&nbsp;
           <c:set var="op_counter" value="${op_counter + 1 }" />
          </c:if>
          <c:if test="${bookitem.state.code eq 1 }">
           <a href="#" onclick="offshelf(${bookitem.beID});return false;" style="color:blue;">下架</a>&nbsp;
           <c:set var="op_counter" value="${op_counter + 1 }" />
          </c:if>
          <c:if test="${bookitem.state.code eq 0 || bookitem.state.code eq 1}">
           <a href="#" data-reveal-id="saModal" data-animation="fade" onclick="loadSA();" style="color:blue;">拍卖</a>&nbsp;
           <c:set var="op_counter" value="${op_counter + 1 }" />
          </c:if>
          <c:if test="${op_counter eq 0 }">
           无
          </c:if>
         </b><br />
        </c:if>
        
       </dt> 
      </dl> 
     </div> 
     <input type="hidden" name="beid" id="beid" value="${bookitem.beID}" /> 
     <input type="hidden" name="redirect_url" id="redirect_url" value="${su:encodeLink(param.redirect_url) }" /> 
    </div> 
   </div> 
  </div> 
  <!--中间部分结束--> 
  <div id="bottom">
   <img src="${staticResources}/image/zhuye_47.gif" width="1024" height="86" alt="" />
  </div> 
  <div id="cpModal" class="reveal-modal"> 
   <iframe id="cp_frame" src="" style=" width:600px; height:290px; margin:0px 0px 0px -35px;" frameborder="0" border="0" marginwidth="0" marginheight="0" scrolling="no" allowtransparency="yes"> </iframe> 
   <a class="close-reveal-modal">&times;</a> 
  </div>
  <div id="saModal" class="reveal-modal" style="width:600px;"> 
   <iframe id="sa_frame" src="" style=" width:640px; height:340px; margin:0px 0px 0px -35px;" frameborder="0" border="0" marginwidth="0" marginheight="0" scrolling="no" allowtransparency="yes"> </iframe> 
   <a class="close-reveal-modal">&times;</a> 
  </div>
 </body>
</html>